<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增app段配置项')" />
    <th:block th:include="include :: bootstrap-select-css" />
    <th:block th:include="include :: summernote-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: bootstrap-editable-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-config-add">

            <div class="form-group">    
                <label class="col-sm-3 control-label">标题：</label>
                <div class="col-sm-8">
                    <input name="title" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">跳转地址：</label>
                <div class="col-sm-8">
                    <input name="url" class="form-control" type="url">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" th:with="type=${@dict.getType('app_config_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">图片地址：</label>
                <div class="col-sm-8">
                    <input type="hidden"  name="img" id="img_url">
                    <div class="file-loading">
                        <input type="file"  name="file" id="img">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-offset-5 col-sm-10">
                    <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js" />
    <th:block th:include="include :: summernote-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-table-editable-js" />
    <script type="text/javascript">

        $("#img").fileinput({
            'theme': 'explorer-fas',
            'uploadUrl': '/common/upload',
            //'deleteUrl': deleteImg(),
            'overwriteInitial': false,
            'maxFileCount':5,
            'elCaptionText':'sss',
            'showUpload':false,
            'initialPreviewAsData': true,
            //'initialPreview': imgData,
            //'initialPreviewConfig': config

        }).on("filebatchselected", function(event, files) { // 选择文件后回调
            $("#img").fileinput("upload");
        }).on("fileuploaded", function(event, data, previewId, index) { // 上传成功回调
            if(data.response.code == 0){
                $("#img_url").val(data.response.url);
            }
        });
        var prefix = ctx + "school/config"
        $("#form-config-add").validate({
            focusCleanup: true
        });

        var List = new Array();
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-config-add').serialize());
            }
        }
    </script>
</body>
</html>